package DataStructure;

import entity.state;

public class node implements Comparable<node> {
	private state s;
	private int depth;
	private int cost;
	private node parent;

	
	public node getParent() {
		return parent;
	}
	public int getCost() {
		return cost;
	}
	public int getDepth() {
		return depth;
	}

	public state getS() {
		return s;
	}

	/* constructors
	 */
	public node() {

	}
	/*
	 * for UCS
	 */
	public node(state s, int cost,node parent) {
		// this.parent=parent;
		this.s = s;
		this.cost = cost;
		this.parent=parent;
	}
	/*
	 * for BFS
	 */
	public node(state s,int cost,int depth,node parent){
		this.s=s;
		this.cost=cost;
		this.depth=depth;
		this.parent=parent;
	}

	/*
	 * Return if it equals to the given node
	 * The compare doesn't involve the parameter cost but just state. 
	 * */
	public boolean StateEquals(node another) {
		return s.eqauls(another.getS());
	}

	/*
	 * override
	 * @see java.lang.Comparable#compareTo(java.lang.Object)
	 * The compare doesn't involve the parameter state but just cost.
	 */
	public int compareTo(node other) { //used for queue sorting by cost
		if(cost<other.getCost())
			return -1;
		else if(cost==other.getCost())
			return 0;
		else return 1;
	}
}
